#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
bool check_day(int& year, int& month, int& day)
{
	if (month == 0 || month > 12) return false;
	if (day == 0) return false;
	if (month != 2)
	{
		if (day > days[month]) return false;
	}
	else
	{
		int leap = year % 100 && year % 4 == 0 || year % 400 == 0;
		if (day > 28 + leap) return false;
	}
	return true;
}

int main()
{
	close();
	int ans=0;
	set<string> cnt{"012","123","234","345","456","567","678","789"};
	for(int date=20220001;date<=20221231;date++)
	{
		int year = date / 10000, month = date % 10000 / 100, day = date % 100;
		if(check_day(year,month,day))
		{
			string s=to_string(date);
			for(int i=0;i<=s.size()-3;i++)
			{
				string t=s.substr(i,3);
				if(cnt.find(t)!=cnt.end())
				{
					ans++;break;
				}
			}
		}
	}

	cout<<ans<<'\n';
	return 0;
}